<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .redBg{
            background: red;
        }
    </style>
</head>
<body>
<div id="app"></div>
<!--react的核心库-->
<script type="text/javascript" src="../utils/react.development.js"></script>
<!--react的扩展库，专门用于操作DOM-->
<script type="text/javascript" src="../utils/react-dom.development.js"></script>
<!--引入babel，用于解析jsx语法为原生js语法-->
<script type="text/javascript" src="../utils/babel.min.js"></script>

<script type="text/babel">
    class MyComponent extends React.Component{
        state={name:"",pwd:"",name1:'',pwd1:""}
        //使用函数柯里化
        GetFormInfo=(propType)=>{
            return(e)=>{
                this.setState({[propType]:e.target.value})
            }
        }
        //通过外层函数传递相应的函数进来
        GetFormInfo2=(e,propType)=>{
            this.setState({[propType]:e.target.value})
        }
            render(){
            return(
                <div>
                    <form action="reactBase/getFormDataUseOneFun?tn=25017023_17_dg">
                        <input type="text" name="name" id="name" onBlur={this.GetFormInfo('name')}/><br/>
                        <input type="text" name="pwd" id="pwd" onBlur={this.GetFormInfo('pwd')}/><br/>
                    </form>
                    <form action="reactBase/getFormDataUseOneFun?tn=25017023_17_dg">
                        <input type="text" name="name1" id="name1" onBlur={(e)=>this.GetFormInfo2(e,'name1')}/><br/>
                        <input type="text" name="pwd1" id="pwd1" onBlur={(e)=>this.GetFormInfo2(e,'pwd1')}/><br/>
                    </form>
                </div>
            )
        }
    }
    ReactDOM.render(<MyComponent/>,document.querySelector('#app'))
</script>
</body>
</html>
